home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / updates / update14.zoo / lib / diffc < prev    next >
Encoding:
Text File  |  1992-01-15  |  46.8 KB  |  1,761 lines

  1. *** 1.61    1991/09/24 16:44:02
  2. --- Changelo    1992/01/14 18:50:57
  3. ***************
  4. *** 2396,2398 ****
  5. --- 2396,2622 ----
  6.   
  7.   
  8.   ---------------------------- Patchlevel 73 ---------------------------
  9. + popen.c:: ++jrb
  10. +     use tmpnam() to get temp filename. That way $TEMP || $TMPDIR
  11. + get looked up.
  12. + main.c:: ++jrb
  13. +     moved clearing of errno to just before calling main(). otherwise
  14. + somehow is was !=0 at the start of main() in some cases.
  15. + unlink.c:: scott
  16. +     i cant believe this was still lurking in there. Thanks scott!!
  17. +     if the file to be unlinked was open, and we put it in the
  18. +     atexit chain, we were'nt strduping the filename, as a result
  19. +     all filenames in the chain were pointing to the same loc.
  20. +     arrgggh! now strdup() the name, and free it in do_deletes. if
  21. +     the strdup() fails, link it in the chain with a null filename,
  22. +     and in do_deletes() just skip over entries with null
  23. +     filenames. we need to do this as we cannot un-atext the entry,
  24. +     nor do we want to as they may be others in the chain before
  25. +     this one, or successive attempts may succeed.
  26. + main.c:: ++jrb
  27. +     call the atexit functions after closing all the open files.
  28. +     this is essential if the deferred unlinks() etc are going to
  29. +     work.
  30. + binmode.c:: ers
  31. +     new file. as per mntlib pl 13, __default_mode__ is now a 
  32. +         global that the user may define. if not defined by the user
  33. +     it gets picked up from here, with a default value of 0 (text mode)
  34. +     the user may now define __default_mode__ = IOBIN; and that
  35. +     way stdin etc get opened in binary mode. thanks eric.
  36. + fdopen.c fopen.c main.c:: ers
  37. +     adjustments for __default_mode__.
  38. + mincl:: ++jrb
  39. +     add target for binmode.o
  40. + localtim.c:: ers
  41. +     sync with mintlib, use symbolic constants
  42. + main.c,spawnve.c,findfile.c: ers
  43. +       when starting up, convert the environment variable PATH to
  44. +       POSIX form (i.e. using ':' as a separator); when execing a
  45. +       new program, convert back to old form so old programs will
  46. +       work correctly. thanks eric.
  47. + fread.c:: jeffrey jackson (jgj@ssd.csd.harris.com)
  48. +     fread was'nt returning EOF on large reads. thanks jeffrey.
  49. + mktemp.c rename.c symlink.c:: ++jrb
  50. +     save errno around calls to access()
  51. + symlink.c:: jeffrey
  52. +     the length returned was wrong because we were doing a strncpy
  53. +     before strlen.
  54. + main.c:: ++jrb
  55. +     for stdin/out/err set open_stat[].filename to the unix device
  56. +     so that fstat() works. thanks to jeffrey for discovering this.
  57. + pipe.c, close.c::  scott
  58. +     minor fixes for pipes. bash-1.10 works real well now.
  59. + stat.c: jeff
  60. +     handle the case for fstat() when stdin/out etc are re-directed.
  61. +     (ie: open_stat[].filename == NULL).
  62. + unx2dos.c:: jeff
  63. +     overwrite __link_to only once when following links, so that
  64. +     lstat() works correctly.
  65. + symlink.c:: jeff
  66. +     readlink didn't work for symbolic links in root file system if
  67. +     the passed name had the slash.  This was because the slashed 
  68. +     was nulled to create the directory name of the file (boundry
  69. +     condition type bug).
  70. + scanf.c:: ++jrb
  71. +     %n was'nt storing the # of chars read in so far, but was storing
  72. +     number of conversions done. thnaks for allan pratt  for reporting
  73. +     this.
  74. + scanf.c:: ++jrb
  75. +     old one had too many subtle problems. replaced with one from
  76. +     gnu libc with a few subtle corrections, and also a bug fix.
  77. +         NOTES:
  78. +     - interface is different from equivalent gnuC lib function
  79. +           it was munged to match our old _scanf().
  80. +     - if __NO_FLOAT__ is defined then the floating point stuff
  81. +       gets nuked (for iio*.olb) as per our old scanf.c.
  82. +        It is very important to read and understand the GNU Library General 
  83. +        Public License. It specifies rights and conditions that are different
  84. +       from the GNU copyleft.
  85. + atof.c:: ++jrb
  86. +     strtod() was leaving the pointer one char too far when input
  87. +     had a tailing 'e' (for example after 100ergs, the endptr would
  88. +     be pointing to 'r' rather than 'e').
  89. + scanf.c:: ++jrb
  90. +     had to hack it quite a bit to get out bugs. the regression test
  91. +     is great now!
  92. + crt0.c:: ++jrb
  93. +      More meanings for _stksize (thanks to eric and allan for the feedback)
  94. +     _stksize            meaning
  95. +       -4L        keep 3/4, free 1/4, malloc from own heap
  96. +       -3L        keep 2/4 (1/2), free 1/2 malloc from own heap
  97. +       -2L        keep 1/4 of memory, free 3/4, malloc from own heap
  98. +     NOTE: all of the following will do malloc from Malloc() first,
  99. +     when that fails, malloc() will do further mallocs from
  100. +     our own heap. This lets us use the maximum amount of
  101. +       memory in traditional ST's as well as newer split address
  102. +     STs.
  103. +       -1L        keep all of memory (except MINFREE at top) and do
  104. +             mallocs from own heap, with heap grown upwards towards
  105. +             stack, and the stack growing down towards heap,
  106. +             with a minimum slush between them so that they
  107. +             dont meet (only checked while malloc'ing). With
  108. +             this model, further spawning is not possible, but it is
  109. +             well suited for programs such as gcc-cc1 etc.
  110. +             Thanks to Piet van Oostrum & Atze Dijkstra for this idea
  111. +     0L        keep minimum amount of memory. this is also the
  112. +             case when _stksize is undefined by the user.
  113. +     1L        keep 1/4 of memory, free 3/4 ( as in Alcyon GEMSTART)
  114. +     2L        keep 2/4 (1/2), free rest
  115. +     3L        keep 3/4, free 1/4
  116. +     other        keep that many bytes
  117. +     -other        keep |other| bytes and malloc from own heap
  118. +     Also note that when _initial_size is specified, malloc happens from own
  119. +     heap only.
  120. + crt0.c:: ++jrb
  121. +     New convention for ACCs: (the old convention is still supported):
  122. +     If _heapbase is not specified by the user, _stksize bytes will
  123. +     be Malloc()'ed from the system, and _heapbase will be set to
  124. +     this area, and sp will be set to the top of the allocated
  125. +     area. All malloc()'s of course will happen from this local heap.
  126. +     The old convention for ACCs where the _heapbase and _stksize
  127. +     were specified, and sp was set to _heapbase+_stksize will
  128. +     continue to work.
  129. + malloc.c, sbrk.c:: ++jrb
  130. +     implement _split_mem for _stksize >= -1L. get mem from
  131. +     Malloc first, after that is exhausted, start carving out of
  132. +     own heap (the heap will be in the other address space of the
  133. +     split address space). (ie: other to the one the program is
  134. +     launched in). The way this is done is that when _stksize >= -1L
  135. +     in crt0.c the vars _split_mem and _heapbase are set in crt0.c.
  136. +     then whenever we sbrk, we first check _split_mem, which if true
  137. +     causes us to Malloc(). Then when Malloc() fails, and if _split_mem
  138. +     was on, we turn it off and that causes sbrk() to start allocing from
  139. +     heap.
  140. + crt0.c:: ++jrb
  141. +     in _start1() the local vars and args MUST be in registers because
  142. +     we are playing games with SP and the FP. to ensure this use
  143. +     __asm("REG") facility of gcc. thanks allan.
  144. + isatty.c:: ++jrb
  145. +     put in a check so that PRN: always returns false. i believe
  146. +     that this will fix the problem of GS and gnuplot,
  147. +     where fwrite() to a file opened in binary mode to PRN: was munging
  148. +     the bytes on the way to the printer. Unfortunately, i dont
  149. +     have a printer attached to my ST to check.
  150. +     Tim says its ok now. GS works!
  151. + unistd.h, mkdir.c:: andreas schwab
  152. +     mkdir takes a second mode argument (currently ignored).
  153. +     thanks andreas.
  154. + basepage.h:: ers
  155. +     make undocumented parts of the BP hard to get at.
  156. + compiler.h:: ers
  157. +     as per mntlib PL16. note that wchar_t is now an int.
  158. + time.h:: ers
  159. +     per mntlib pl 16
  160. + sys/timeb.h:: ers
  161. +     new file
  162. + timeoday.c:: ers
  163. +     New file.
  164. +     New BSD-ish ftime(), gettimeofday() and settimeofday() system calls.
  165. + mincl:: ers
  166. +     add target for timeoday.
  167. + spawnve.c:: ers
  168. +     use TOS_ARGS instead of NCARGS
  169. + pipe.c:: ers/scott
  170. +     Eric beet down the MiNT/PIPE bug, and I must say with two trivial 
  171. +     changes the dup2/pipe interface works quite well. Under MiNT
  172. +     file handles are not automatically shared with children. So
  173. +     the dup2 in bash/emacs was failing.
  174. + getpass.c, mincl, unistd.h :: ers
  175. +     new file from mintlib for getpass(). Add target to mincl. Add
  176. +     proto to unistd.h. Note: you need to put the final '\n' yourself,
  177. +     after the call to getpass().
  178. + getpass.c:: ++jrb
  179. +     Null terminate return string (was being passed back with \n)
  180. +     If fget retuns a Null pass back Null (per man on the sun).
  181. + gmon.c:: ++jrb
  182. +     we collectively decided that all xbra's should be chained via
  183. +     the next's. make adjustments to unlink_handler.
  184. + ---------------------------- Patchlevel 74 ---------------------------
  185. *** 1.49    1991/09/24 16:44:02
  186. --- PatchLev.h    1992/01/14 18:50:58
  187. ***************
  188. *** 1,5 ****
  189.   
  190. ! #define    PatchLevel "73"
  191.   
  192.   /*
  193.    *
  194. --- 1,5 ----
  195.   
  196. ! #define    PatchLevel "74"
  197.   
  198.   /*
  199.    *
  200. *** 1.18    1991/05/30 04:10:51
  201. --- atof.c    1992/01/14 18:51:05
  202. ***************
  203. *** 239,244 ****
  204. --- 239,245 ----
  205.       register short texp  = 0;
  206.       register short e     = 0;
  207.       double       zero = 0.0;
  208. +     const char        *tmp;
  209.   
  210.       assert ((s != NULL));
  211.   
  212. ***************
  213. *** 280,286 ****
  214.       {
  215.       if(*++s != '\0') /* skip e|E|d|D */
  216.       {  /* ! ([s]xxx[.[yyy]]e)  */
  217.           while(Isspace(*s)) s++; /* Ansi allows spaces after e */
  218.           if(*s != '\0')
  219.           { /*  ! ([s]xxx[.[yyy]]e[space])  */
  220. --- 281,287 ----
  221.       {
  222.       if(*++s != '\0') /* skip e|E|d|D */
  223.       {  /* ! ([s]xxx[.[yyy]]e)  */
  224. !         tmp = s;
  225.           while(Isspace(*s)) s++; /* Ansi allows spaces after e */
  226.           if(*s != '\0')
  227.           { /*  ! ([s]xxx[.[yyy]]e[space])  */
  228. ***************
  229. *** 303,308 ****
  230. --- 304,310 ----
  231.               texp += e;
  232.           }
  233.           }
  234. +         if(s == tmp) s++;    /* back up pointer for a trailing e|E|d|D */
  235.       }
  236.       }
  237.   
  238. *** 1.12    1991/09/24 16:44:02
  239. --- close.c    1992/01/14 18:51:08
  240. ***************
  241. *** 3,59 ****
  242.    *     Copyright (c) 1988, Memorial University of Newfoundland
  243.    *
  244.    */
  245.   #include    <osbind.h>
  246.   #include    <fcntl.h>
  247.   #include    <device.h>
  248.   #include    <stdlib.h>
  249.   
  250.   #ifdef DEBUG
  251.   #include <stdio.h>
  252.   #endif
  253.   
  254.   int close(fd)
  255. !     int    fd;
  256.   {
  257. !         int     oldfd;
  258. !     extern    int    errno;
  259. !     int        rval;
  260. !     struct _device    *dev;
  261. !     if ((dev = _dev_fd(fd)) && dev->close)
  262. !         return (*dev->close)(fd);
  263. !         oldfd = fd;
  264. !     fd = __OPEN_INDEX(fd);
  265. !     if ((fd >= 0) && (fd < __NHANDLES))
  266.       {
  267. !         if (__open_stat[fd].pipe)
  268. !             {
  269.           rval = pipeclose(oldfd);
  270. !         return(rval);
  271. !             }
  272. !             else 
  273.           if((__open_stat[fd].status == FH_ISAFILE) &&
  274.              (__open_stat[fd].filename))
  275.               free(__open_stat[fd].filename);
  276. !         __open_stat[fd].status = FH_UNKNOWN;
  277. !         __open_stat[fd].append = 0;
  278. !         __open_stat[fd].nodelay = 0;
  279. !             __open_stat[fd].pipe = 0;
  280. !         __open_stat[fd].eclose = 0;
  281. !         __open_stat[fd].filename = (char *) 0;
  282. !     }
  283. !     if ((rval = Fclose(oldfd)) < 0) {
  284. !         errno = -rval;
  285. !         rval = -1;
  286. !     }
  287.   #ifdef DEBUG
  288. !     fprintf(stderr, "close(%d)->%d\n", (fd + __SMALLEST_VALID_HANDLE),
  289. !          rval);
  290.   #endif
  291. !     return rval;
  292.   }
  293.   
  294. --- 3,67 ----
  295.    *     Copyright (c) 1988, Memorial University of Newfoundland
  296.    *
  297.    */
  298. + #include     <compiler.h>
  299.   #include    <osbind.h>
  300.   #include    <fcntl.h>
  301.   #include    <device.h>
  302.   #include    <stdlib.h>
  303.   
  304. + __EXTERN int pipeclose __PROTO((int fd));
  305.   #ifdef DEBUG
  306.   #include <stdio.h>
  307.   #endif
  308.   
  309.   int close(fd)
  310. ! int    fd;
  311.   {
  312. !     int     oldfd;
  313. !     extern    int    errno;
  314. !     int        rval;
  315. !     struct _device    *dev;
  316. !     
  317. !     if ((dev = _dev_fd(fd)) && dev->close)
  318. !     return (*dev->close)(fd);
  319. !     oldfd=fd;
  320. !     fd = __OPEN_INDEX(fd);
  321. !     
  322. !     if ((fd >= 0) && (fd < __NHANDLES))
  323. !     {
  324. !     if (__open_stat[fd].pipe)
  325.       {
  326. !         if (oldfd < 3)
  327. !         {
  328. !         __open_stat[fd].pipe = 0;
  329. !         rval = close(oldfd);
  330. !         }
  331. !         else 
  332.           rval = pipeclose(oldfd);
  333. !         return(rval);
  334. !     }
  335. !     else 
  336.           if((__open_stat[fd].status == FH_ISAFILE) &&
  337.              (__open_stat[fd].filename))
  338.               free(__open_stat[fd].filename);
  339. !     __open_stat[fd].status = FH_UNKNOWN;
  340. !     __open_stat[fd].append = 0;
  341. !     __open_stat[fd].nodelay = 0;
  342. !     __open_stat[fd].pipe = 0;
  343. !     __open_stat[fd].eclose = 0;
  344. !     __open_stat[fd].filename = (char *) 0;
  345. !     }
  346. !     
  347. !     if ((rval = Fclose(oldfd)) < 0) {
  348. !     errno = -rval;
  349. !     rval = -1;
  350. !     }
  351. !     
  352.   #ifdef DEBUG
  353. !     fprintf(stderr, "close(%d)->%d\n", (fd + __SMALLEST_VALID_HANDLE),
  354. !         rval);
  355.   #endif
  356. !     return rval;
  357.   }
  358.   
  359. *** 1.17    1991/09/24 16:44:02
  360. --- crt0.c    1992/01/14 18:51:08
  361. ***************
  362. *** 15,21 ****
  363. --- 15,34 ----
  364.    * 01/03/89 ++jrb
  365.    *    The (new) meaning of _stksize: (thanks to allan pratt for the feedback)
  366.    *
  367. +  * 11/27/91 ++jrb
  368. +  *     More meanings for _stksize (thanks to eric and allan for the feedback)
  369. +  *
  370.    *    _stksize            meaning
  371. +  *      -4L        keep 3/4, free 1/4, malloc from own heap
  372. +  *      -3L        keep 2/4 (1/2), free 1/2 malloc from own heap
  373. +  *      -2L        keep 1/4 of memory, free 3/4, malloc from own heap
  374. +  *
  375. +  *    NOTE: all of the following will do malloc from Malloc() first,
  376. +  *    when that fails, malloc() will do further mallocs from
  377. +  *    our own heap. This lets us use the maximum amount of
  378. +  *      memory in traditional ST's as well as newer split address
  379. +  *    STs.
  380. +  *
  381.    *      -1L        keep all of memory (except MINFREE at top) and do
  382.    *            mallocs from own heap, with heap grown upwards towards
  383.    *            stack, and the stack growing down towards heap,
  384. ***************
  385. *** 31,37 ****
  386.    *    2L        keep 2/4 (1/2), free rest
  387.    *    3L        keep 3/4, free 1/4
  388.    *    other        keep that many bytes
  389. !  *    -other        keep all BUT that many bytes
  390.    *
  391.    * 02/14/90 ++jrb (thanks edgar)
  392.    *    auto acc detect
  393. --- 44,50 ----
  394.    *    2L        keep 2/4 (1/2), free rest
  395.    *    3L        keep 3/4, free 1/4
  396.    *    other        keep that many bytes
  397. !  *    -other        keep |other| bytes and malloc from own heap
  398.    *
  399.    * 02/14/90 ++jrb (thanks edgar)
  400.    *    auto acc detect
  401. ***************
  402. *** 52,57 ****
  403. --- 65,73 ----
  404.    *         at startup, sp will be set to top of this area
  405.    *         (_heapbase  + _stksize ) and malloc()'s will happen from heap.
  406.    *        (note malloc() and *not* Malloc())
  407. +  *     OR
  408. +  *    user sets only _stksize. then _heapbase is set to Malloc(_stksize)
  409. +  *    sp to _heapbase + _stksize and mallocs all happen from this heap.
  410.    *
  411.    * 02/16/90 ++jrb
  412.    *  - bug fix: dont get screwed by desktop launch when fast bit is set
  413. ***************
  414. *** 101,106 ****
  415. --- 117,125 ----
  416.   /* are we an app? */
  417.   short _app;
  418.   
  419. + /* are we on a split addr mem ST */
  420. + short _split_mem = 0;
  421.   static void _acc_main __PROTO((void));
  422.   static void _start1 __PROTO((BASEPAGE *bp));
  423.   static long parseargs __PROTO((BASEPAGE *bp));
  424. ***************
  425. *** 148,154 ****
  426. --- 167,189 ----
  427.        jeq    __start0         /* br if prog          */
  428.       tstl    a0@(36)             /* tst parent basepage pointer */
  429.       jne     __start0         /* its a prog if != 0  */
  430. +  /* its an acc, set up a stck+heap */
  431.        movl    a0,__base         /* sto basepage    */
  432. +     tstl    __heapbase         /* setup _heapbase and sp */
  433. +     jne    1f
  434. +     movl    __stksize,d3         /* _heapbase not specified */
  435. +         addql    #3, d3
  436. +     andl    #0xfffffffc,d3
  437. +     movl    d3,sp@-             /* _heapbase = Malloc(_stksize) */
  438. +         movw    #0x48,sp@-
  439. +     trap    #1
  440. +     addqw    #6,sp
  441. +     movl    d0, __heapbase
  442. +     addl    d3,d0
  443. +     movl    d0, sp              /* sp = _heapbase + _stksize */
  444. +     jra    __acc_main
  445. + 1:                     /* heap base specified */
  446.        movl    __heapbase,sp         /* setup sp        */
  447.        addl    __stksize,sp        
  448.        jra    __acc_main");           /* acc main          */
  449. ***************
  450. *** 179,188 ****
  451.   }
  452.   
  453.   static void _start1(bp)
  454. !     register BASEPAGE *bp;
  455.   {
  456. !     register long m;
  457. !     register long freemem;
  458.       
  459.       _app = 1;    /* its an application */
  460.       _base = bp;
  461. --- 214,223 ----
  462.   }
  463.   
  464.   static void _start1(bp)
  465. !     register BASEPAGE *bp __asm("a3");
  466.   {
  467. !     register long m __asm("d3");
  468. !     register long freemem __asm("d4");
  469.       
  470.       _app = 1;    /* its an application */
  471.       _base = bp;
  472. ***************
  473. *** 205,213 ****
  474.           _stksize = _initial_stack;
  475.       }
  476.       
  477.       switch(_stksize)
  478.       {
  479. !       case -1L:    /* keep all but MINFREE, and malloc from own heap */
  480.           _stksize = freemem;
  481.           _heapbase = (void *) ((long)bp->p_tbase + m);
  482.           break;
  483. --- 240,259 ----
  484.           _stksize = _initial_stack;
  485.       }
  486.       
  487. +     if((_stksize < 0) && (_stksize != -1L))
  488. +     {
  489. +         _heapbase = (void *) ((long)bp->p_tbase + m);
  490. +         _stksize = -_stksize - 1;
  491. +         }
  492. +         
  493. +     if((!_initial_stack) && (_stksize >= -1L))
  494. +         {   /* keep all, malloc from Malloc first, then from own heap */
  495. +         _split_mem = 1;
  496. +         }
  497.       switch(_stksize)
  498.       {
  499. !       case -1L:    /* keep all but MINFREE */
  500.           _stksize = freemem;
  501.           _heapbase = (void *) ((long)bp->p_tbase + m);
  502.           break;
  503. ***************
  504. *** 227,238 ****
  505.         case 3L:    /* keep 3/4, free 1/4 */
  506.           _stksize = freemem - (freemem >> 2); 
  507.           break;
  508. !         
  509.         default:
  510. -         if(_stksize < 0) /* keep all but |_stksize| */
  511. -         if((_stksize = freemem + _stksize) <= 0L)
  512. -             goto notenough;
  513.           /* if _stksize > 0, keep that much */
  514.       }
  515.       
  516.   /* make m the total number of bytes including stack */
  517. --- 273,282 ----
  518.         case 3L:    /* keep 3/4, free 1/4 */
  519.           _stksize = freemem - (freemem >> 2); 
  520.           break;
  521.         default:
  522.           /* if _stksize > 0, keep that much */
  523. +         break;
  524.       }
  525.       
  526.   /* make m the total number of bytes including stack */
  527. *** 1.1    1991/07/23 22:06:28
  528. --- fcntl.c    1992/01/14 18:51:13
  529. ***************
  530. *** 7,12 ****
  531. --- 7,13 ----
  532.   #include <fcntl.h>
  533.   #include <stdarg.h>
  534.   #include <errno.h>
  535. + #include <unistd.h>
  536.   
  537.   #ifdef __STDC__
  538.   int fcntl (int f, int cmd, ...)
  539. *** 1.7    1991/04/26 03:42:08
  540. --- fdopen.c    1992/01/14 18:51:13
  541. ***************
  542. *** 10,16 ****
  543.       register int h;
  544.       const register char *mode;
  545.       {
  546. !     extern int __default_mode__;    /* see fopen.c */
  547.       register int i, iomode = 0, f = __default_mode__;
  548.       register FILE *fp = NULL;
  549.       void _getbuf(FILE *);
  550. --- 10,16 ----
  551.       register int h;
  552.       const register char *mode;
  553.       {
  554. !     extern int __default_mode__;    /* see binmode.c */
  555.       register int i, iomode = 0, f = __default_mode__;
  556.       register FILE *fp = NULL;
  557.       void _getbuf(FILE *);
  558. *** 1.8    1991/04/26 03:42:08
  559. --- findfile.c    1992/01/14 18:51:14
  560. ***************
  561. *** 19,26 ****
  562.   #endif
  563.   
  564.   /* characters used to separate components in a path list */
  565. ! #define PATHSEP1        ','
  566. ! #define PATHSEP2        ';'
  567.   
  568.   /* characters used to separate directory names in a file */
  569.   #define DIRSEP1         '\\'    /* native OS directory separator */
  570. --- 19,26 ----
  571.   #endif
  572.   
  573.   /* characters used to separate components in a path list */
  574. ! #define PATHSEP1        ':'
  575. ! #define PATHSEP2        ','
  576.   
  577.   /* characters used to separate directory names in a file */
  578.   #define DIRSEP1         '\\'    /* native OS directory separator */
  579. *** 1.14    1991/09/24 16:44:02
  580. --- fopen.c    1992/01/14 18:51:15
  581. ***************
  582. *** 13,41 ****
  583.   /* lowest character device handle # */
  584.   #define    LAST_DEVICE    __SMALLEST_VALID_HANDLE
  585.   
  586. ! /*
  587. !  * added _binmode()
  588. !  *    if called with TRUE, then subsequently all fopens have _IOBIN
  589. !  *    by default  on open. This will make life much easier for
  590. !  *    people who have been using the Gnu lib (any my job with the compiler
  591. !  *    much easier too, dont't have to go hunting for fopens())
  592. !  *                ++jrb;
  593. !  */
  594.   
  595. - /* note, cant be static as fdopen.c uses it too, so does libg++ */
  596. - int __default_mode__ = 0;
  597.   static FILE *_fopen __PROTO((const char *filename, const char *mode, FILE *fp));
  598. - void _binmode(force)
  599. - int force;
  600. - {
  601. -     if(force)
  602. -     __default_mode__ = _IOBIN;
  603. -     else
  604. -     __default_mode__ = 0;
  605. - }
  606.   
  607.   static FILE *_fopen(filename, mode, fp)
  608.       const char *filename;
  609. --- 13,21 ----
  610.   /* lowest character device handle # */
  611.   #define    LAST_DEVICE    __SMALLEST_VALID_HANDLE
  612.   
  613. ! extern int __default_mode__;
  614.   
  615.   static FILE *_fopen __PROTO((const char *filename, const char *mode, FILE *fp));
  616.   
  617.   static FILE *_fopen(filename, mode, fp)
  618.       const char *filename;
  619. *** 1.9    1991/04/23 16:04:12
  620. --- fread.c    1992/01/14 18:51:17
  621. ***************
  622. *** 62,68 ****
  623.           }
  624.           else
  625.           { /* read in n bytes into data */
  626. !         l += _read(fp->_file, data, (unsigned long)n);
  627.           }
  628.       }
  629.       ret:
  630. --- 62,75 ----
  631.           }
  632.           else
  633.           { /* read in n bytes into data */
  634. !         if((cnt = _read(fp->_file, data, (unsigned long)n))<=0) {
  635. !             fp->_flag |= ((cnt == 0) ? _IOEOF : _IOERR);
  636. !             goto ret;
  637. !         }
  638. !                 data+=cnt;
  639. !                 l+=cnt;
  640. !                 n-=cnt;
  641. !                 goto again;
  642.           }
  643.       }
  644.       ret:
  645. *** 1.6    1991/06/23 17:07:09
  646. --- gmon.c    1992/01/14 18:51:24
  647. ***************
  648. *** 622,628 ****
  649.       }
  650.       /* otherwise find me in the chain and unlink */
  651.       save_ssp = Super(0L);
  652. !     for(prev = this; this && (this != me); prev = this, this = this->next)
  653.       {
  654.       /* validate the xbra */
  655.       if(this->xbra_magic != _XBRA_MAGIC) 
  656. --- 622,630 ----
  657.       }
  658.       /* otherwise find me in the chain and unlink */
  659.       save_ssp = Super(0L);
  660. !     for(prev = this; this && (this != me); prev = this,
  661. !         this = (xbra_struct *)((this->next)
  662. !          ? (((char *)(this->next)) - offsetof(xbra_struct, jump)) : 0))
  663.       {
  664.       /* validate the xbra */
  665.       if(this->xbra_magic != _XBRA_MAGIC) 
  666. *** 1.6    1991/04/26 03:42:08
  667. --- ioctl.c    1992/01/14 18:51:25
  668. ***************
  669. *** 12,17 ****
  670. --- 12,18 ----
  671.   #include     <osbind.h>
  672.   #include    <device.h>
  673.   #include    <unistd.h>
  674. + #include    <linea.h>    /* for TIOCGWINSZ under TOS */
  675.   
  676.   int
  677.   ioctl(fd, func, arg)
  678. ***************
  679. *** 81,86 ****
  680. --- 82,101 ----
  681.           __tchars[TC_WERASC] = ltc->t_werasc;
  682.           __tchars[TC_LNEXTC] = ltc->t_lnextc;
  683.           break;
  684. +     case TIOCSWINSZ:
  685. +             break;
  686. +     case TIOCGWINSZ:
  687. +         {
  688. +         struct winsize *win = (struct winsize *)arg;
  689. +         (void)linea0();
  690. +         win->ws_row = V_CEL_MY + 1;
  691. +         win->ws_col = V_CEL_MX + 1;
  692. +         win->ws_xpixel = V_X_MAX;
  693. +         win->ws_ypixel = V_Y_MAX;
  694. +         }
  695.   
  696.       default:
  697.           errno = EINVAL;
  698. *** 1.8    1991/04/26 03:42:08
  699. --- isatty.c    1992/01/14 18:51:25
  700. ***************
  701. *** 19,27 ****
  702.     if ((short)handle < 0)
  703.       return(1);
  704.   
  705. !   if ((dev = _dev_fd(fd)) && dev->open)    /* a special device */
  706. !     return 0;
  707.     if (handle < __NHANDLES)
  708.       if (__open_stat[handle].status != FH_UNKNOWN)
  709.           return(__open_stat[handle].status == FH_ISATTY);
  710. --- 19,30 ----
  711.     if ((short)handle < 0)
  712.       return(1);
  713.   
  714. !   dev = _dev_fd(fd);
  715. !   if (dev && ((dev->open) || (dev->dev == 0xfffd)))
  716. !   {    /* a special device or PRN: */
  717. !       return 0;
  718. !   }
  719. !   
  720.     if (handle < __NHANDLES)
  721.       if (__open_stat[handle].status != FH_UNKNOWN)
  722.           return(__open_stat[handle].status == FH_ISATTY);
  723. *** 1.4    1991/06/11 23:04:27
  724. --- lib.h    1992/01/14 18:51:26
  725. ***************
  726. *** 44,49 ****
  727.   __EXTERN char *_itoa __PROTO((int, char *, int));
  728.   
  729.   #endif /* _LIB_H */
  730. --- 44,46 ----
  731. *** 1.11    1991/04/26 03:42:08
  732. --- localtim.c    1992/01/14 18:51:27
  733. ***************
  734. *** 73,81 ****
  735.       y = (t->tm_mday - 1) + mth_start[t->tm_mon] + /* leap year correction */
  736.           ( ( (t->tm_year % 4) != 0 ) ? 0 : (t->tm_mon > 1) );
  737.   
  738. !     s = (t->tm_sec) + (t->tm_min * 60L) + (t->tm_hour * 3600L) +
  739. !         (y * 86400L) + ((t->tm_year - 70) * 31536000L) +
  740. !         ((t->tm_year - 69)/4) * 86400L;
  741.   
  742.   /* Now adjust for the time zone and possible daylight savings time */
  743.   /* note that we have to call tzset() every time; see 1003.1 sect 8.1.1 */
  744. --- 73,81 ----
  745.       y = (t->tm_mday - 1) + mth_start[t->tm_mon] + /* leap year correction */
  746.           ( ( (t->tm_year % 4) != 0 ) ? 0 : (t->tm_mon > 1) );
  747.   
  748. !     s = (t->tm_sec)+(t->tm_min*SECS_PER_MIN)+(t->tm_hour*SECS_PER_HOUR) +
  749. !         (y*SECS_PER_DAY)+((t->tm_year - 70)*SECS_PER_YEAR) +
  750. !         ((t->tm_year - 69)/4)*SECS_PER_DAY;
  751.   
  752.   /* Now adjust for the time zone and possible daylight savings time */
  753.   /* note that we have to call tzset() every time; see 1003.1 sect 8.1.1 */
  754. *** 1.19    1991/05/23 14:43:17
  755. --- main.c    1992/01/14 18:51:27
  756. ***************
  757. *** 54,59 ****
  758. --- 54,62 ----
  759.   /* supplied by the user */
  760.   __EXTERN int main __PROTO((int, char **, char **));
  761.   
  762. + /* in getbuf.c */
  763. + __EXTERN void _getbuf __PROTO((FILE *));
  764.   void
  765.   _main(_argc, _argv, _envp)
  766.       long _argc;
  767. ***************
  768. *** 62,69 ****
  769.       char *tty;
  770.       register FILE *f;
  771.       register int i;
  772. !     void _getbuf(FILE *);
  773. !     extern int __default_mode__;
  774.       int main(int, char **, char **);
  775.   
  776.       _start_time = 0;    /* for dumped prgs */
  777. --- 65,72 ----
  778.       char *tty;
  779.       register FILE *f;
  780.       register int i;
  781. !      char *s, *t, *new;
  782. !     extern int __default_mode__; /* in binmode.c or defined by user */
  783.       int main(int, char **, char **);
  784.   
  785.       _start_time = 0;    /* for dumped prgs */
  786. ***************
  787. *** 70,76 ****
  788.       _start_time = clock();
  789.       _child_runtime = _sys_runtime = 0;
  790.       num_at_exit = 0;
  791. -     errno = 0;
  792.   /*
  793.    * check for MiNT
  794.    */
  795. --- 73,78 ----
  796. ***************
  797. *** 97,107 ****
  798.       if(!*_argv[0] && isatty(2))
  799.           (void)Fforce(2, _console_dev - 3);
  800.   
  801. - /*
  802. -  * FIX_ME: we should check to see if _binmode(TRUE) was set because
  803. -  * of UNIXMODE.
  804. -  */
  805.       stdin->_flag = _IOREAD|_IOFBF|__default_mode__;
  806.       stdout->_flag = _IOWRT|_IOLBF|__default_mode__;
  807.       stderr->_flag = _IORW|_IONBF|__default_mode__;
  808. --- 99,104 ----
  809. ***************
  810. *** 120,126 ****
  811.       }
  812.   
  813.       for(i = 0; i <= __OPEN_INDEX(2); i++) {
  814. !         __open_stat[i].filename = NULL;
  815.       }
  816.   
  817.        for(i = 3; i < _NFILE; i++, f++) {
  818. --- 117,125 ----
  819.       }
  820.   
  821.       for(i = 0; i <= __OPEN_INDEX(2); i++) {
  822. !         __open_stat[i].filename = isatty(i) ? 
  823. !             ((_console_dev == 2) ? "/dev/console" : "/dev/tty1")
  824. !                 : (char *)NULL; /* if it was re-dir */
  825.       }
  826.   
  827.        for(i = 3; i < _NFILE; i++, f++) {
  828. ***************
  829. *** 127,132 ****
  830. --- 126,165 ----
  831.         f->_flag = 0;        /* clear flags, if this is a dumped program */
  832.       }
  833.   
  834. +     /* Fix up environment, if necessary. At present, the only variable
  835. +      * affected is PATH; the "standard" path separators for PATH are
  836. +      * ',' and ';' in the Atari world, but POSIX mandates ':'. This
  837. +      * conflicts with the use of ':' as a drive separator, so we
  838. +      * also convert names like A:\foo to /dev/A/foo
  839. +      * NOTE: this conversion must be undone in spawn.c so that
  840. +      * old fashioned programs will understand us!
  841. +      */
  842. +     for (i = 0; s = _envp[i]; i++) {    /* '=', NOT '==' */
  843. +         if (s[0] == 'P' && s[1] == 'A' && s[2] == 'T' &&
  844. +             s[3] == 'H' && s[4] == '=') {
  845. +             new = alloca(4*strlen(s));
  846. +             strncpy(new, s, 5);
  847. +             t = new+5;
  848. +             s += 5;
  849. +             while (*s) {
  850. +                 if (s[1] == ':') {    /* drive letter */
  851. +                     *t++ = '/';
  852. +                     *t++ = 'd'; *t++ = 'e'; *t++ = 'v';
  853. +                     *t++ = '/'; *t++ = *s++; s++;
  854. +                 } else if (*s == ';' || *s == ',') {
  855. +                     *t++ = ':'; s++;
  856. +                 } else {
  857. +                     *t++ = *s++;
  858. +                 }
  859. +             }
  860. +             *t++ = 0;
  861. +             _envp[i] = strdup(new);
  862. +             break;
  863. +         }
  864. +     }
  865. +     errno = 0;
  866.       /* ANSI-Draft: A return from the initial call to the main      */
  867.       /* function is equivalent to calling the exit function with    */
  868.       /* the value returned by the main function as its argument. If */
  869. ***************
  870. *** 147,154 ****
  871.   {
  872.       register int i, f;
  873.   
  874. -     for(i = num_at_exit - 1; i >= 0; --i)
  875. -         (*_at_exit[i])();
  876.   
  877.       for(i=0; i<_NFILE; ++i) {
  878.           f = _iob[i]._flag;
  879. --- 180,185 ----
  880. ***************
  881. *** 158,163 ****
  882. --- 189,198 ----
  883.               else
  884.                   fclose(&_iob[i]);
  885.       }
  886. +     for(i = num_at_exit - 1; i >= 0; --i)
  887. +         (*_at_exit[i])();
  888.       _exit(status);
  889.   }
  890.   
  891. *** 1.17    1991/09/24 16:44:02
  892. --- malloc.c    1992/01/14 18:51:28
  893. ***************
  894. *** 46,51 ****
  895. --- 46,52 ----
  896.     struct mem_chunk *p, *q;
  897.     long sz;
  898.     extern void *_heapbase;
  899. +   extern short _split_mem;
  900.   
  901.   /* add a mem_chunk to required size and round up */
  902.     n = n + sizeof(struct mem_chunk);
  903. ***************
  904. *** 63,69 ****
  905.   /* if not enough memory, get more from the system */
  906.     if (q == NULL) 
  907.       {
  908. !     if ((_heapbase != NULL) || (n > MINHUNK))
  909.           sz = n;
  910.       else {
  911.           sz = MINHUNK;
  912. --- 64,70 ----
  913.   /* if not enough memory, get more from the system */
  914.     if (q == NULL) 
  915.       {
  916. !     if (((!_split_mem) && (_heapbase != NULL)) || (n > MINHUNK))
  917.           sz = n;
  918.       else {
  919.           sz = MINHUNK;
  920. ***************
  921. *** 108,113 ****
  922. --- 109,115 ----
  923.     struct mem_chunk *o, *p, *q, *s;
  924.     struct mem_chunk *r = (struct mem_chunk *) param;
  925.     extern void *_heapbase;
  926. +   extern short _split_mem;
  927.   
  928.   /* free(NULL) should do nothing */
  929.     if (r == 0)
  930. ***************
  931. *** 155,161 ****
  932.       r->size = 0;
  933.       r->next = NULL;
  934.       s = (struct mem_chunk * )(((long) p) + p->size);
  935. !     if (_heapbase != NULL && s >= (struct mem_chunk *) _heapbase) {
  936.         assert(s == _heapbase);
  937.         _heapbase = (char *) p;
  938.         _stksize += p->size;
  939. --- 157,163 ----
  940.       r->size = 0;
  941.       r->next = NULL;
  942.       s = (struct mem_chunk * )(((long) p) + p->size);
  943. !     if ((!_split_mem) && _heapbase != NULL && s >= (struct mem_chunk *) _heapbase) {
  944.         assert(s == _heapbase);
  945.         _heapbase = (char *) p;
  946.         _stksize += p->size;
  947. ***************
  948. *** 165,171 ****
  949.       else
  950.           {
  951.         s = (struct mem_chunk * )(((long) r) + r->size);
  952. !       if (_heapbase != NULL && s >= (struct mem_chunk *) _heapbase) {
  953.           assert(s == _heapbase);
  954.           _heapbase = (char *) r;
  955.           _stksize += r->size;
  956. --- 167,173 ----
  957.       else
  958.           {
  959.         s = (struct mem_chunk * )(((long) r) + r->size);
  960. !       if ((!_split_mem) && _heapbase != NULL && s >= (struct mem_chunk *) _heapbase) {
  961.           assert(s == _heapbase);
  962.           _heapbase = (char *) r;
  963.           _stksize += r->size;
  964. *** 1.12    1991/09/24 16:44:02
  965. --- mincl    1992/01/14 18:51:30
  966. ***************
  967. *** 13,19 ****
  968.   
  969.   GCC=     $(GLIB1) $(GLIB2) \
  970.       ldexp.o frexp.o modf.o alloca.o setjmp.o osbind.o\
  971. !     linea.o  alglobal.o sysvar.o gmon.o screen.o stksiz.o
  972.   #
  973.   # ANSI stuff + support
  974.   ANSI =  atol.o atof.o abort.o bsearch.o clock.o ctime.o ctype.o difftime.o \
  975. --- 13,19 ----
  976.   
  977.   GCC=     $(GLIB1) $(GLIB2) \
  978.       ldexp.o frexp.o modf.o alloca.o setjmp.o osbind.o\
  979. !     linea.o  alglobal.o sysvar.o gmon.o screen.o stksiz.o binmode.o
  980.   #
  981.   # ANSI stuff + support
  982.   ANSI =  atol.o atof.o abort.o bsearch.o clock.o ctime.o ctype.o difftime.o \
  983. ***************
  984. *** 31,38 ****
  985.   #
  986.   # other portable stuff
  987.   PORT =  alphasor.o abs.o catch.o dirent.o findfile.o ftw.o getpw.o \
  988. !     getlogin.o getopt.o ident.o mktemp.o scandir.o strlwr.o strrev.o \
  989. !     regexp.o regsup.o textio.o random.o
  990.   
  991.   #
  992.   # the string library
  993. --- 31,38 ----
  994.   #
  995.   # other portable stuff
  996.   PORT =  alphasor.o abs.o catch.o dirent.o findfile.o ftw.o getpw.o \
  997. !     getlogin.o getopt.o getpass.o ident.o mktemp.o scandir.o strlwr.o \
  998. !     strrev.o regexp.o regsup.o textio.o random.o
  999.   
  1000.   #
  1001.   # the string library
  1002. ***************
  1003. *** 49,55 ****
  1004.       link.o lseek.o mkdir.o null.o open.o perror.o pipe.o popen.o psignal.o \
  1005.       read.o rename.o rmdir.o \
  1006.       sbrk.o sgtty.o signal.o siglist.o sleep.o spawnve.o spawnvp.o stat.o \
  1007. !     symdir.o symlink.o tchars.o time.o times.o \
  1008.       unlink.o unx2dos.o utime.o vfork.o write.o
  1009.   
  1010.   #
  1011. --- 49,55 ----
  1012.       link.o lseek.o mkdir.o null.o open.o perror.o pipe.o popen.o psignal.o \
  1013.       read.o rename.o rmdir.o \
  1014.       sbrk.o sgtty.o signal.o siglist.o sleep.o spawnve.o spawnvp.o stat.o \
  1015. !     symdir.o symlink.o tchars.o time.o timeoday.o times.o \
  1016.       unlink.o unx2dos.o utime.o vfork.o write.o
  1017.   
  1018.   #
  1019. *** 1.8    1991/06/11 23:04:27
  1020. --- mkdir.c    1992/01/14 18:51:31
  1021. ***************
  1022. *** 11,18 ****
  1023.   
  1024.   extern int errno;
  1025.   
  1026. ! int mkdir(_path)
  1027.   const char *_path;
  1028.   {
  1029.       int rv, name_munged;
  1030.       char path[FILENAME_MAX];
  1031. --- 11,19 ----
  1032.   
  1033.   extern int errno;
  1034.   
  1035. ! int mkdir(_path, mode)
  1036.   const char *_path;
  1037. + int mode;
  1038.   {
  1039.       int rv, name_munged;
  1040.       char path[FILENAME_MAX];
  1041. *** 1.9    1991/05/23 14:43:17
  1042. --- mktemp.c    1992/01/14 18:51:31
  1043. ***************
  1044. *** 8,13 ****
  1045. --- 8,14 ----
  1046.   #include <fcntl.h>
  1047.   #include <unistd.h>
  1048.   #include <assert.h>
  1049. + #include <errno.h>
  1050.   #include "lib.h"
  1051.   
  1052.   #define TEN_MUL(X)    ((((X) << 2) + (X)) << 1)
  1053. ***************
  1054. *** 18,23 ****
  1055. --- 19,25 ----
  1056.     char * p, * q;
  1057.     long tempnum, nx;
  1058.     static int startat = 0;
  1059. +   int save_errno;
  1060.   
  1061.     assert((pattern != NULL));
  1062.   
  1063. ***************
  1064. *** 39,49 ****
  1065. --- 41,56 ----
  1066.     }
  1067.     else 
  1068.         startat++;
  1069. +   save_errno = errno;
  1070.     for(; tempnum < nx; tempnum++)
  1071.     {
  1072.       (void) _ltoa(tempnum, q, 10); /* assumption: strrev reverses in place */
  1073.       if(access(pattern, F_OK))    /* using access takes care of unx2dos also */
  1074. +     {
  1075. +     errno = save_errno;
  1076.       return pattern;
  1077. +     }
  1078.     }
  1079. +   errno = save_errno;
  1080.     return NULL;
  1081.   }
  1082. *** 1.1    1991/09/24 16:44:02
  1083. --- pipe.c    1992/01/14 18:51:33
  1084. ***************
  1085. *** 4,10 ****
  1086. --- 4,14 ----
  1087.   #include <errno.h>
  1088.   #include <stdio.h>
  1089.   #include <stdlib.h>
  1090. + #define __MINT__
  1091. + #include <mintbind.h>
  1092.   
  1093. + extern int __mint;
  1094.   /**
  1095.    ** (sjk)++ These routines simulate a eunchs pipe() call using temporary 
  1096.    **         files. A linked list of type *_pipe is kept as to allow as 
  1097. ***************
  1098. *** 23,28 ****
  1099. --- 27,33 ----
  1100.              struct _pipe *next;
  1101.                };
  1102.   static struct _pipe *__pipes = NULL;
  1103. + static int del_list (struct _pipe *);
  1104.   
  1105.   /*---------------------------------------------------------------------------*/
  1106.   /* Make a pipe, open the tempory file, set it up for writing, add the pipe   */
  1107. ***************
  1108. *** 41,46 ****
  1109. --- 46,55 ----
  1110.     /*----------------------------------------------*/
  1111.     fd = open(name,O_CREAT | O_TRUNC | O_RDWR | O_PIPE, 0644); 
  1112.   
  1113. + #if defined(DEBUG)
  1114. +   fprintf(stderr,"opened pipe - fd : %d.\n",fd);
  1115. + #endif
  1116.     if (fd < 0)
  1117.       fprintf(stderr,"fd returns : %d! PIPE(%s) failed.\n",fd, name);
  1118.     else 
  1119. ***************
  1120. *** 60,65 ****
  1121. --- 69,76 ----
  1122.         __pipes     = p;
  1123.         /*-------------------------------------------------------------------*/ 
  1124.         fildes[0] = fildes[1] = fd;       /* we fill in fildes[].            */
  1125. +       if (__mint)
  1126. +     Fcntl(fd,0L,2);                 /* Make fd shared across Pexecs()  */
  1127.       }
  1128.     return(fd);                           /* Return the file descriptor.     */
  1129.   }
  1130. ***************
  1131. *** 77,82 ****
  1132. --- 88,97 ----
  1133.      int    ifd;
  1134.      for (p=__pipes; p; p=p->next)
  1135.       { if (fd == p->file_des) 
  1136. +        { 
  1137. + #if defined(DEBUG)
  1138. +         fprintf(stderr,"Deleting pipe - mode : %c, fd : %d\n",p->flag,fd);
  1139. + #endif
  1140.           if (p->flag == 'r') 
  1141.         { int res;
  1142.           ifd = __OPEN_INDEX(fd);
  1143. ***************
  1144. *** 92,97 ****
  1145. --- 107,113 ----
  1146.               lseek(p->file_des,0,SEEK_SET);         /* read from the start.  */
  1147.               return(0);
  1148.             }
  1149. +       }
  1150.       }
  1151.      fprintf(stderr,"attempt to close nonexistant pipe.\n");
  1152.      return(-1);
  1153. ***************
  1154. *** 100,106 ****
  1155.   /*---------------------------------------------------------------------*/
  1156.   /* delete a pipe descriptor from our list of pipes rooted ar __pipes.  */
  1157.   /*---------------------------------------------------------------------*/
  1158. ! del_list(p)
  1159.   struct _pipe *p;
  1160.   { struct _pipe *q,*r;
  1161.     
  1162. --- 116,122 ----
  1163.   /*---------------------------------------------------------------------*/
  1164.   /* delete a pipe descriptor from our list of pipes rooted ar __pipes.  */
  1165.   /*---------------------------------------------------------------------*/
  1166. ! static int del_list(p)
  1167.   struct _pipe *p;
  1168.   { struct _pipe *q,*r;
  1169.     
  1170. ***************
  1171. *** 110,116 ****
  1172.         return(0);
  1173.       }
  1174.     else 
  1175. !     { r = p->next; q = p;               /* No it is interior.           */
  1176.         for (; r; r = r->next)
  1177.           { if (r == p)
  1178.              { q->next = r->next;              /* pass over it.   */
  1179. --- 126,132 ----
  1180.         return(0);
  1181.       }
  1182.     else 
  1183. !     { r = __pipes->next; q = __pipes;    /* No it is interior.           */
  1184.         for (; r; r = r->next)
  1185.           { if (r == p)
  1186.              { q->next = r->next;              /* pass over it.   */
  1187. ***************
  1188. *** 121,125 ****
  1189.       }
  1190.       }
  1191.     fprintf(stderr,"Attempt to delete a nonexisting pipe form list (__pipes).");
  1192.   }
  1193. --- 137,141 ----
  1194.       }
  1195.       }
  1196.     fprintf(stderr,"Attempt to delete a nonexisting pipe form list (__pipes).");
  1197. +   return(-1);
  1198.   }
  1199. *** 1.3    1991/04/12 18:19:53
  1200. --- popen.c    1992/01/14 18:51:33
  1201. ***************
  1202. *** 29,35 ****
  1203.       char    pmode;        /* "r" or "w" to/from the pipe ?    */
  1204.       char    *pcommand;    /* cmd to execute (only for "w")    */
  1205.       int    pstat;        /* exit code of cmd (only for "r")    */
  1206. !     char    pname[20];    /* temp filename. 20 should be enough...*/
  1207.       FILE    *pfile;        /* pipe identifier            */
  1208.       struct _pipe    *pnext;    /* next pipe in the list.        */
  1209.       };
  1210. --- 29,35 ----
  1211.       char    pmode;        /* "r" or "w" to/from the pipe ?    */
  1212.       char    *pcommand;    /* cmd to execute (only for "w")    */
  1213.       int    pstat;        /* exit code of cmd (only for "r")    */
  1214. !     char    pname[32];    /* temp filename. 32 should be enough...*/
  1215.       FILE    *pfile;        /* pipe identifier            */
  1216.       struct _pipe    *pnext;    /* next pipe in the list.        */
  1217.       };
  1218. ***************
  1219. *** 36,43 ****
  1220.   
  1221.   static struct _pipe    *__pipes = NULL;    /* head of pipe list    */
  1222.   
  1223. - static char        ptmp[] = "pipeXXXX";    /* skeleton for temp filename */
  1224.   /* open a pipe to the command argument in the mode given by the type string.
  1225.    * If caller wants to read the pipe, redirect output and execute command,
  1226.    * then open the temp file and return that. If caller wants to write to
  1227. --- 36,41 ----
  1228. ***************
  1229. *** 55,64 ****
  1230.       /* initialize the new pipe entry */
  1231.       p->pmode = *type;
  1232.       p->pfile = (FILE *) NULL;
  1233. !     strcpy(p->pname,ptmp);
  1234. !     mktemp(p->pname);
  1235.       /* make command line with appropriate re-direction */
  1236. !     if((p->pcommand = (char *)malloc(strlen(command)+strlen(ptmp)+4L))
  1237.           == (char *)NULL)
  1238.       {    /* no  mem */
  1239.           free(p);
  1240. --- 53,61 ----
  1241.       /* initialize the new pipe entry */
  1242.       p->pmode = *type;
  1243.       p->pfile = (FILE *) NULL;
  1244. !     (void)tmpnam(p->pname);
  1245.       /* make command line with appropriate re-direction */
  1246. !     if((p->pcommand = (char *)malloc(strlen(command)+strlen(p->pname)+4L))
  1247.           == (char *)NULL)
  1248.       {    /* no  mem */
  1249.           free(p);
  1250. *** 1.13    1991/06/11 23:04:27
  1251. --- rename.c    1992/01/14 18:51:35
  1252. ***************
  1253. *** 18,23 ****
  1254. --- 18,24 ----
  1255.       SYMDIR *olddir = 0, *newdir = 0;
  1256.       SYMENTRY *ent = 0, *old;
  1257.       char *s;
  1258. +     int save_errno = errno;
  1259.   
  1260.       if (!access(_newname, 0)) {    /* new name already exists */
  1261.   #ifdef DEBUG
  1262. ***************
  1263. *** 26,31 ****
  1264. --- 27,33 ----
  1265.           if (unlink(_newname))
  1266.               return -1;
  1267.       }
  1268. +     errno = save_errno;
  1269.   
  1270.       rval = unx2dos(_oldname, oldname);
  1271.       /* unx2dos returns _NM_LINK and sets __link_path and __link_name if
  1272. *** 1.7    1991/06/23 17:07:09
  1273. --- sbrk.c    1992/01/14 18:51:36
  1274. ***************
  1275. *** 15,20 ****
  1276. --- 15,21 ----
  1277.   
  1278.   extern void *_heapbase;
  1279.   extern long _stksize;
  1280. + extern short _split_mem;
  1281.   
  1282.   static void * HeapAlloc( sz )
  1283.   size_t sz ;
  1284. ***************
  1285. *** 43,49 ****
  1286.   {
  1287.     void *rval;
  1288.   
  1289. !   if(_heapbase != NULL)
  1290.     {
  1291.         if(n) rval = HeapAlloc(n);
  1292.         else  rval = _heapbase;
  1293. --- 44,50 ----
  1294.   {
  1295.     void *rval;
  1296.   
  1297. !   if((!_split_mem) && (_heapbase != NULL))
  1298.     {
  1299.         if(n) rval = HeapAlloc(n);
  1300.         else  rval = _heapbase;
  1301. ***************
  1302. *** 54,59 ****
  1303. --- 55,65 ----
  1304.     }
  1305.     if (rval == NULL)
  1306.     {
  1307. +       if(_split_mem)
  1308. +       {  /* now switch over to own heap for further requests, including this one */
  1309. +       _split_mem = 0;
  1310. +       return lsbrk(n);
  1311. +       }
  1312.         errno = ENOMEM;
  1313.         rval = (void *)-1;
  1314.     }
  1315. *** 1.14    1991/07/23 22:06:28
  1316. --- spawnve.c    1992/01/14 18:51:39
  1317. ***************
  1318. *** 22,27 ****
  1319. --- 22,28 ----
  1320.   #include    <time.h>
  1321.   #include    <string.h>
  1322.   #include    <fcntl.h>
  1323. + #include    <unistd.h>
  1324.   #include    "lib.h"
  1325.   
  1326.   extern char **environ;
  1327. ***************
  1328. *** 29,35 ****
  1329.   clock_t _child_runtime;
  1330.   clock_t _sys_runtime;
  1331.   
  1332. ! static    char    cmd[NCARGS+1];
  1333.   
  1334.   /*
  1335.    * FIXME: currently mode == P_OVERLAY doesn't work as advertised, i.e. it
  1336. --- 30,37 ----
  1337.   clock_t _child_runtime;
  1338.   clock_t _sys_runtime;
  1339.   
  1340. ! #define TOS_ARGS 126
  1341. ! static    char    cmd[TOS_ARGS+1];
  1342.   
  1343.   /*
  1344.    * FIXME: currently mode == P_OVERLAY doesn't work as advertised, i.e. it
  1345. ***************
  1346. *** 73,85 ****
  1347.           return -1;
  1348.       }
  1349.       s = env;
  1350. !     while (*envp) {
  1351. !         for (p = *envp ; *p ; )
  1352. !             *s++ = *p++;
  1353.           *s++ = '\0';
  1354.           envp++;
  1355.       }
  1356. -     
  1357.       strcpy(s, "ARGV=");
  1358.       s += 6; /* s+=sizeof("ARGV=") */
  1359.   
  1360. --- 75,108 ----
  1361.           return -1;
  1362.       }
  1363.       s = env;
  1364. !     while ((p = *envp) != 0) {
  1365. ! /*
  1366. !  * NOTE: in main.c, we converted the PATH environment variable into
  1367. !  * POSIX form. Here, we convert back into gulam form. Note that the
  1368. !  * new variable will be shorter than the old, so space is not a problem.
  1369. !  */
  1370. !         if (!strncmp(p, "PATH=", 5)) {
  1371. !             strncpy(s, p, 5); s += 5; p += 5;
  1372. !             while (*p) {
  1373. !                 if (!strncmp(p, "/dev/", 5) && p[5]) {
  1374. !                     *s++ = p[5];
  1375. !                     *s++ = ':';
  1376. !                     p += 6;
  1377. !                 } else if (*p == ':') {
  1378. !                     *s++ = ','; p++;
  1379. !                 } else if (*p == '/') {
  1380. !                     *s++ = '\\'; p++;
  1381. !                 } else {
  1382. !                     *s++ = *p++;
  1383. !                 }
  1384. !             }
  1385. !         } else {
  1386. !             while(*p)
  1387. !                 *s++ = *p++;
  1388. !         }
  1389.           *s++ = '\0';
  1390.           envp++;
  1391.       }
  1392.       strcpy(s, "ARGV=");
  1393.       s += 6; /* s+=sizeof("ARGV=") */
  1394.   
  1395. ***************
  1396. *** 100,111 ****
  1397.           while (*++argv) {
  1398.               p = *argv;
  1399.               while (*p) {
  1400. !                               if (cmlen <= NCARGS) {
  1401.                                         *t++ = *p; cmlen++;
  1402.                                 }
  1403.                   *s++ = *p++;
  1404.               }
  1405. !                         if (cmlen <= NCARGS && *(argv+1)) {
  1406.                                   *t++ = ' '; cmlen++;
  1407.                           }
  1408.                   *s++ = '\0';
  1409. --- 123,134 ----
  1410.           while (*++argv) {
  1411.               p = *argv;
  1412.               while (*p) {
  1413. !                               if (cmlen <= TOS_ARGS) {
  1414.                                         *t++ = *p; cmlen++;
  1415.                                 }
  1416.                   *s++ = *p++;
  1417.               }
  1418. !                         if (cmlen <= TOS_ARGS && *(argv+1)) {
  1419.                                   *t++ = ' '; cmlen++;
  1420.                           }
  1421.                   *s++ = '\0';
  1422. *** 1.15    1991/07/23 22:06:28
  1423. --- stat.c    1992/01/14 18:51:40
  1424. ***************
  1425. *** 245,251 ****
  1426.       int old;
  1427.       int r;
  1428.       struct _device *dev = _dev_fd(fd);
  1429.       if(dev)
  1430.       {
  1431.       char *devname = (char *)alloca(strlen(dev->unxnm) + 6L);
  1432. --- 245,251 ----
  1433.       int old;
  1434.       int r;
  1435.       struct _device *dev = _dev_fd(fd);
  1436. !     
  1437.       if(dev)
  1438.       {
  1439.       char *devname = (char *)alloca(strlen(dev->unxnm) + 6L);
  1440. ***************
  1441. *** 253,270 ****
  1442.       (void) strcat(devname, dev->unxnm);
  1443.       return stat(devname, st);
  1444.       }
  1445.       fd = __OPEN_INDEX(fd);
  1446.       if((fd >= 0) && (fd < __NHANDLES))
  1447.       {
  1448. ! /* we should turn off links, because the name we're going to give
  1449. !  * to 'stat' has already been unx2dos'd
  1450. !  */
  1451. !     old = _lOK;
  1452. !     _lOK = 0;
  1453. !     r = stat(__open_stat[fd].filename, st);
  1454. !     _lOK = old;
  1455. !     return r;
  1456.       }
  1457.       errno = EBADF;
  1458.       return -1;
  1459. --- 253,323 ----
  1460.       (void) strcat(devname, dev->unxnm);
  1461.       return stat(devname, st);
  1462.       }
  1463. !     
  1464.       fd = __OPEN_INDEX(fd);
  1465.       if((fd >= 0) && (fd < __NHANDLES))
  1466.       {
  1467. !     if (__open_stat[fd].filename) {
  1468. !         /* we should turn off links, because the name we're going to give
  1469. !          * to 'stat' has already been unx2dos'd
  1470. !          */
  1471. !         old = _lOK;
  1472. !         _lOK = 0;
  1473. !         r = stat(__open_stat[fd].filename, st);
  1474. !         _lOK = old;
  1475. !         return r;
  1476. !     } else {
  1477. !         _DOSTIME timestruct;
  1478. !         
  1479. !         /* the following code is stolen from Eric R. Smith */
  1480. !         r = Fdatime(×truct, fd, 0);
  1481. !         if (r < 0) {            /* assume TTY */
  1482. !         st->st_mode = S_IFCHR | 0600;
  1483. !         st->st_attr = 0;
  1484. !         st->st_mtime = st->st_ctime = st->st_atime =
  1485. !             time((time_t *)0) - 2;
  1486. !         st->st_size = 0;
  1487. !         } else {
  1488. !         long oldplace;
  1489. !         
  1490. !         st->st_mtime = st->st_atime = st->st_ctime =
  1491. !             unixtime(timestruct.time,timestruct.date);
  1492. !         st->st_mode = S_IFREG | 0644;        /* this may be false */
  1493. !         st->st_attr = 0;            /* because this is */
  1494. !         
  1495. !         /* get current file location */
  1496. !         oldplace = Fseek(0L, fd, SEEK_CUR);
  1497. !         if (oldplace < 0) {        /* can't seek -- must be pipe */
  1498. !             st->st_mode = S_IFIFO | 0644;
  1499. !             st->st_size = 1024;
  1500. !         } else {
  1501. !             short magic;
  1502. !             r = Fseek(0L, fd, SEEK_END);    /* go to end of file */
  1503. !             st->st_size = r;
  1504. !             (void)Fseek(0L, fd, SEEK_SET);    /* go to start of file */
  1505. !             /* check for executable file */
  1506. !             if (_x_Bit_set_in_stat && 
  1507. !             Fread(fd, 2, (char *)&magic) == 2) {
  1508. !             if (magic == 0x601a || magic == 0x2321)
  1509. !                 st->st_mode |= 0111;
  1510. !             }
  1511. !             (void)Fseek(oldplace, fd, SEEK_SET);
  1512. !         }
  1513. !         }
  1514. !         
  1515. !         /* all this stuff is likely bogus as well. sigh. */
  1516. !         st->st_dev = Dgetdrv();
  1517. !         st->st_rdev = 0;
  1518. !         st->st_uid = getuid();
  1519. !         st->st_gid = getgid();
  1520. !         st->st_blksize = 1024;
  1521. !         /* note: most Unixes measure st_blocks in 512 byte units */
  1522. !         st->st_blocks = (st->st_size + 511) / 512;
  1523. !         st->st_ino = ++__inode;
  1524. !         st->st_nlink = 1;
  1525. !         return 0;
  1526. !         
  1527. !     }
  1528.       }
  1529.       errno = EBADF;
  1530.       return -1;
  1531. *** 1.7    1991/06/11 23:04:27
  1532. --- symlink.c    1992/01/14 18:51:47
  1533. ***************
  1534. *** 21,27 ****
  1535.       SYMDIR *dir;
  1536.       SYMENTRY *d;
  1537.       char *s;
  1538. !     int r;
  1539.   
  1540.   /* Problem: to TOS, "Makefile", "Makefile", and "makefilefoo" are all
  1541.    * identical. Fortunately, unx2dos can distinguish them, and
  1542. --- 21,27 ----
  1543.       SYMDIR *dir;
  1544.       SYMENTRY *d;
  1545.       char *s;
  1546. !     int r, save_errno;
  1547.   
  1548.   /* Problem: to TOS, "Makefile", "Makefile", and "makefilefoo" are all
  1549.    * identical. Fortunately, unx2dos can distinguish them, and
  1550. ***************
  1551. *** 33,43 ****
  1552. --- 33,45 ----
  1553.    * is redundant).
  1554.    */
  1555.   
  1556. +         save_errno = errno;
  1557.       r = unx2dos(new, linkpath);
  1558.       if ((r == _NM_LINK) || (r == _NM_OK) && !access(new, 0)) {
  1559.           errno = EEXIST;
  1560.           return -1;
  1561.       }
  1562. +     errno = save_errno;
  1563.   
  1564.   /*
  1565.    * find the name (from the original path in "new"), and the canonical form
  1566. ***************
  1567. *** 99,104 ****
  1568. --- 101,107 ----
  1569.       char tmp[FILENAME_MAX], linkpath[FILENAME_MAX], *s, *lastslash = 0;
  1570.       SYMDIR *dir;
  1571.       SYMENTRY *ent;
  1572. +         size_t len;
  1573.   
  1574.       strcpy(tmp, filename);
  1575.       for (s = tmp; *s; s++) {
  1576. ***************
  1577. *** 105,111 ****
  1578.           if (*s == '\\' || (_tSLASH && (*s == '/')))
  1579.               lastslash = s;
  1580.       }
  1581. !     if (lastslash) {
  1582.           *lastslash++ = 0;
  1583.           unx2dos(tmp, linkpath);
  1584.       }
  1585. --- 108,117 ----
  1586.           if (*s == '\\' || (_tSLASH && (*s == '/')))
  1587.               lastslash = s;
  1588.       }
  1589. !         if (lastslash==tmp) {
  1590. !             lastslash++;
  1591. !             unx2dos("/",linkpath);
  1592. !         } else if (lastslash) {
  1593.           *lastslash++ = 0;
  1594.           unx2dos(tmp, linkpath);
  1595.       }
  1596. ***************
  1597. *** 123,128 ****
  1598.           return -1;
  1599.       }
  1600.       strncpy(linkto, ent->linkto, siz);
  1601.       _free_symdir(dir);
  1602. !     return strlen(linkto);
  1603.   }
  1604. --- 129,140 ----
  1605.           return -1;
  1606.       }
  1607.       strncpy(linkto, ent->linkto, siz);
  1608. +         /* must get length right */
  1609. +         len=strlen(ent->linkto);
  1610. +         if (len>siz) {
  1611. +            len=siz;
  1612. +         }
  1613.       _free_symdir(dir);
  1614. !     return len;
  1615.   }
  1616. *** 1.17    1991/06/23 17:07:09
  1617. --- unlink.c    1992/01/14 18:51:50
  1618. ***************
  1619. *** 13,18 ****
  1620. --- 13,19 ----
  1621.   #include "lib.h"
  1622.   
  1623.   #define error(x) ((errno = (x)), -1)
  1624. + __EXTERN char *strdup __PROTO((const char *s));
  1625.   
  1626.   /* remove provided for ansi compatibility */
  1627.   #ifndef __GNUC__
  1628. ***************
  1629. *** 35,42 ****
  1630.   
  1631.       d = D;
  1632.       while (d) {
  1633.           (void)Fdelete(d->fname);
  1634. !         d = d->next;
  1635.       }
  1636.   }
  1637.   
  1638. --- 36,46 ----
  1639.   
  1640.       d = D;
  1641.       while (d) {
  1642. +         if(d->fname) {
  1643.           (void)Fdelete(d->fname);
  1644. !         free(d->fname);
  1645. !         }
  1646. !         d = d->next;
  1647.       }
  1648.   }
  1649.   
  1650. ***************
  1651. *** 98,105 ****
  1652.                   return error(ENOMEM);
  1653.               }
  1654.       /* hook the new "delete" structure into the chain */
  1655. !             d->fname = name;
  1656.               d->next = D; D = d;
  1657.       /* if there was an automatic link, delete it now */
  1658.               if (ent)
  1659.                   goto unlink_sym;
  1660. --- 102,119 ----
  1661.                   return error(ENOMEM);
  1662.               }
  1663.       /* hook the new "delete" structure into the chain */
  1664. !             d->fname = strdup(name);
  1665.               d->next = D; D = d;
  1666. +             if(!(d->fname)) {
  1667. +                 /* note we link it in and then check, as
  1668. +                    we cannot undo the atexit(), (nor do we
  1669. +                    want to because there maybe others on the
  1670. +                    chain already). in do_deletes we'll
  1671. +                    just skip the null name entries */
  1672. +                 _free_symdir(dir);
  1673. +                 return error(ENOMEM);
  1674. +             }
  1675. +             
  1676.       /* if there was an automatic link, delete it now */
  1677.               if (ent)
  1678.                   goto unlink_sym;
  1679.